In the computer field there are two major approaches for handling file accesses: stateless and state-full. In the stateless approach, the information needed to access a file is sent with each file access request. In the state-full approach, a file is opened with certain attributes such as read only, locked, shared, and the like, and a handle is returned to the opened file. In each subsequent request for access to the file, the client sends the received handle together with any access request (e.g., read request, write request, or request to modify one or more attributes). The file system uses the handle to locate state regarding the file and processes the request.
Each approach to handling file accesses has advantages and disadvantages. In the stateless approach, a great deal of information is typically passed with each request. With each request, a client may be required to send data that identifies the file together with information that authenticates the client. A server receiving a request for a file access from the client may be required to authenticate the client and determine whether the client has rights to access the file in the manner requested. If a client frequently accesses a file to read or write small chunks of data, considerable overhead may occur for the client, the network or networks over which the access request passes, and a server servicing the file access request. In addition, a client may be required to keep track of where in the file the next read or write should occur. In stateless file accesses, a client is typically not allowed to lock a file for the client's exclusive use, as this requires state.
In the state-full approach, there are problems associated with what to do with an open file if a client crashes. A file that is opened and locked by a client that crashes may remain locked until a system administrator or other entity having authority over the file determines that the lock should be released. If a file lock is released and the client has not crashed but instead is just taking a long time to make its next file access request, this may cause errors on the client and/or consistency problems with the file.
Alternatively, or in addition, upon a client crash or connection disruption, a file may be closed and some state information associated with the file may be disposed of. When the file is re-opened, this state information may need to be reconstructed, resulting in extra processing and overhead.
What is needed is a method and system to provide fast state-full access to files while avoiding the disadvantages associated with state-full access.